//
//  SEGVisitorAccessDoorViewCell.m
//  ExcellentHome
//
//  Created by 揭婧雯 on 2017/5/12.
//  Copyright © 2017年 陈区. All rights reserved.
//

#import "SEGVisitorAccessDoorViewCell.h"

@implementation SEGVisitorAccessDoorViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = kColor_W;

    UIImage *img = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select_nor")];
    UIImageView *iconView = [[UIImageView alloc] initWithImage:img];
    [self.contentView addSubview:iconView];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).with.offset(-15);
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(img.size.width);
    }];
    self.selectImage = iconView;
    
    UILabel *lable = [[UILabel alloc] init];
    lable.font = kFont_16;
    lable.textColor = kColor_1;
    [self.contentView addSubview:lable];
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(15);
        make.right.equalTo(iconView.mas_left).with.offset(-15);
        make.centerY.equalTo(self.contentView);
    }];
    self.lable = lable;
}

- (void)updateDoorCellWithName:(NSString *)name isSelected:(BOOL)isSelected
{
    self.lable.text = name;
    if (isSelected) {
        self.selectImage.image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select")];
        self.lable.textColor = kColor_T;
    }else{
        self.selectImage.image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select_nor")];
        self.lable.textColor = kColor_1;
    }
}
@end
